# Maintainer: Andrzej Giniewicz <gginiu@gmail.com>
# Maintainer: Bruno Pagani <archange@archlinux.org>
# Contributor: Oliver Sherouse <oliver DOT sherouse AT gmail DOT com>

pkgname=python-statsmodels
pkgver=0.13.5
pkgrel=3
pkgdesc="Statistical computations and models for use with SciPy"
arch=(loong64 x86_64)
url="https://www.statsmodels.org/"
license=(BSD)
depends=(python-numpy python-scipy python-pandas python-patsy)
makedepends=(python-setuptools-scm cython git)
optdepends=('jupyter-notebook: needed to run the notebooks'
            'python-cvxopt: regularized fitting of some models'
            'python-joblib: accelerate distributed estimation for certain models'
            'python-matplotlib: plotting functions')
checkdepends=(python-pytest python-pytest-xdist python-joblib python-matplotlib)
source=(git+https://github.com/statsmodels/statsmodels#tag=v$pkgver)
sha256sums=('SKIP')

build() {
  cd statsmodels
  python setup.py build
}

check() {
  local python_version=$(python -c 'import sys; print(".".join(map(str, sys.version_info[:2])))')
  cd statsmodels/build/lib.linux-${CARCH}-cpython-${python_version/./}
  PYTHONPATH="${PWD}" pytest -vv --color=yes statsmodels || echo "Tests failed"
}

package() {
  cd statsmodels
  python setup.py install --skip-build --root="${pkgdir}" --optimize=1
  install -Dm644 LICENSE.txt -t "${pkgdir}"/usr/share/licenses/${pkgname}
}
